home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_08 / 9n08098b < prev    next >
Text File  |  1991-06-15  |  838b  |  29 lines

  1.  
  2. int allocate_space(int nbr, char ***ptrarray, int size, char **string)
  3.     {  //Allocate the array pointers       
  4.     if( (*ptrarray= (char **)calloc(nbr,sizeof(char *))) ==NULL)
  5.         return(0);       //Allocate the string space  ***       
  6.     if( (*string = (char *)calloc(size+1,sizeof(char))) == NULL)
  7.         return(0);       
  8.     return(1);  
  9.     }  
  10.  
  11. void free_space(char ***ptrarray, char **string)
  12.     {
  13.     free(*ptrarray);      
  14.     free(*string);  
  15.     }
  16.  
  17.   void str_to_ptrarray(char *orgstr, char *ptrarray[])
  18.     {       
  19.     int i=0;  
  20.     char *s;       
  21.     s=strtok(orgstr,word_breaks); //Find the first word       
  22.     while(*s)
  23.         {
  24.         ptrarray[i]=s;      //assign it  
  25.         i++;  
  26.         s=strtok(NULL,word_breaks);   //Find the rest of the words       
  27.         }
  28.     }
  29.